package cn.smile.dao;

import cn.smile.pojo.User;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: MaoSuyu
 * @User：John
 * @Date: 2019/7/4
 * @Time: 19:47
 * @Description: No Description
 */
@Repository
public interface RoleDaoMapper {

    /**
     * 根据用户id查询角色
     * @param user
     * @return
     */
    @Select("SELECT role FROM user_role ur INNER JOIN role r ON ur.roleId=r.id WHERE ur.userId=#{id}")
    List<String> selectRoleById(User user);

    /**
     * 查询全部权限
     * @return
     */
    @Select("SELECT role FROM role WHERE role IS NOT NULL")
    List<String> selectAll();

}
